<?php
	class ChartAction extends Action {
		public function pie($size="340,200",$picsize="90",$title="",$data="",$legends=""){
			vendor('jpgraph.jpgraph');
			vendor('jpgraph.jpgraph_pie');
			vendor('jpgraph.jpgraph_pie3d');
			$tmp=explode(",", $size);
			$chartSize["width"]=$tmp[0];
			$chartSize["height"]=$tmp[1];
			$chartData=explode(",", $data);
			$legends=iconv("UTF-8", "GB2312", $legends);
			$chartLegends=explode("|", $legends);
			$chartTitle = $title;
			$chartTitle = iconv("UTF-8", "gb2312", $chartTitle);
			// Create the Pie Graph.
			$data = $chartData;
			$graph = new PieGraph($chartSize["width"],$chartSize["height"]);
			$graph->SetShadow();
			
			// Set A title for the plot
			
			$graph->title->Set($chartTitle);
			$graph->title->SetFont(FF_SIMSUN,FS_BOLD,18);
			$graph->title->SetColor("darkblue");
			$graph->legend->Pos(0.1,0.2);
			
			// Create 3D pie plot
			$p1 = new PiePlot3d($data);
			$p1->SetTheme("sand");
			$p1->SetCenter(0.4);
			$p1->SetSize($picsize);
			
			// Adjust projection angle
			$p1->SetAngle(45);
			
			// Adjsut angle for first slice
			$p1->SetStartAngle(45);
			
			// Display the slice values
			$p1->value->SetFont(FF_SIMSUN,FS_NORMAL,11);
			$p1->value->SetColor("navy");
			
			// Add colored edges to the 3D pie
			// NOTE: You can't have exploded slices with edges!
			$p1->SetEdge("navy");
			$graph->legend->SetLayout(LEGEND_VERT);
			$p1->SetLegends($chartLegends);
			
			$graph->Add($p1);
			$graph->Stroke();
		}
		public function zhu($size="340,200",$title="",$xy="",$data1="",$data2=""){
			vendor('jpgraph.jpgraph');
			vendor('jpgraph.jpgraph_bar');
			$tmp=explode(",", $size);
			$chartSize["width"]=$tmp[0];
			$chartSize["height"]=$tmp[1];
			$datay1=explode(",", $data1);
			$datay2=explode(",", $data2);
			
			$data1y=explode(",", $data1);
			$data2y=explode(",", $data2);
			$tmp=explode(",", $size);
			$chartSize["width"]=$tmp[0];
			$chartSize["height"]=$tmp[1];
			$xy=iconv("UTF-8", "gb2312", $xy);
			$chartXY=explode(",", $xy);
			// Create the graph. These two calls are always required
			$graph = new Graph($chartSize["width"],$chartSize["height"]);
			$graph->SetScale("textlin");
			
			$graph->SetShadow();
			$graph->img->SetMargin(40,30,20,40);
			
			// Create the bar plots
			$b1plot = new BarPlot($data1y);
			$b1plot->SetFillColor("orange");
			$b1plot->value->Show();
			$b2plot = new BarPlot($data2y);
			$b2plot->SetFillColor("blue");
			$b2plot->value->Show();
			
			// Create the grouped bar plot
			$gbplot = new AccBarPlot(array($b1plot,$b2plot));
			
			// ...and add it to the graPH
			$graph->Add($gbplot);
			
			$chartTitle = $title;
			$chartTitle = iconv("UTF-8", "gb2312", $chartTitle);
			$graph->title->Set($chartTitle);
			$graph->xaxis->title->Set($chartXY[0]);
			$graph->yaxis->title->Set($chartXY[1]);
			
			$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
			$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
			$graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
			
			// Display the graph
			$graph->Stroke();
			
		}
	}

?>